package signGrammar.expressions;

import java.util.LinkedHashMap;
import java.util.Map;

import signGrammar.IShape;
import signGrammar.expressions.util.EExpressionElementClass;

public class CGrammarContext implements IGrammarContext {
	private Map<String, IShape> factories = new LinkedHashMap<String, IShape>();
	
	@Override public IGrammarContext assign(String varName, IShape value) {
		factories.put( EExpressionElementClass.parseVarType(varName), value);
		return this;
	}
	
	@Override public IShape find(String varName) {
		String type = EExpressionElementClass.parseVarType(varName);
		return factories.get(type).cloneForHead( factories.get(type).getHead() );
	}
	
	@Override public CVariable getVariable(String varName){
		return CVariable.create(varName);
	}
	
	@Override public Map<String, IShape> getPrimitives(){
		return factories;
	}
}
